Consider the situation that you are now a programmer of some renown. A potential customer comes to you with a problem. All that is needed is a program which will take eleven cricket scores and place them in ascending order. OK you say and start to think about the problem.
When you are designing a program you should think in terms of the variables and the data storage first, and then write the code which will manipulate them. We need to hold 11 scores, so we need 11 variables. From what we know of cricket, we find that cricketers can score more than 255 runs (unless they play for England of course) and so we would not have room in a character type variable. Therefore we would declare the variables like this:
int s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11 ;
We now have enough variables to hold 11 cricket scores. If we assume that the numbers have been read in somehow (we will come to input and output real soon I promise) then all we have to do is print the numbers out in ascending order. If we use simple variables like the above we find that this task is a nightmare. We could write an if construction which said something like:
if ((s1>s2)&&(s1>s3)&&(s1>s4) &&(s1>s5)&&(s1>s6)&&(s1>s7) &&(s1>s8)&&(s1>s9)&&(s1>s10)) { /* if we get here */ /* s1 is the biggest */ }
This is a horrible construction, and it only returns true if s1 is the biggest value. We would have to do something similar to test all the other values, just to find out if they are the biggest. We would then have to do something even more complicated, eleven times, just to find out which is the second biggest, and so on. If, by some miracle, we get it to work we would find it virtually impossible to sort 100 scores, since the program would be enormous.